package com.jianli.smart.aop.demo;

import java.lang.reflect.Method;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jianli.smart.aop.AspectProxy;
import com.jianli.smart.aop.annotation.Aspect;
import com.jianli.smart.core.annotation.Service;

@Aspect(Service.class)
public class ServiceAspect extends AspectProxy{
	private static final Logger LOGGER = LoggerFactory.getLogger(ServiceAspect.class);
	
	private long begin;
	
	@Override
	public void before(Class<?> cls, Method method, Object[] params)
			throws Throwable {
		LOGGER.debug("service start");
		begin = System.currentTimeMillis();
	}
	
	@Override
	public void after(Class<?> cls, Method method, Object[] params)
			throws Throwable {
		LOGGER.debug("service cost time:"+(System.currentTimeMillis() - begin));
		LOGGER.debug("service end");
	}
}
